<?php
session_start();

//if form was already submitted and with values
if (isset($_POST['submit'])) {
    $date = $_POST['dateAgenda'];
    $place = $_POST['placeAgenda'];
    $desc = $_POST['descAgenda'];
    $sTimeAgenda = $_POST['sTimeAgenda'];
    $eTimeAgenda = $_POST['eTimeAgenda'];

    include 'DBLibrary/config.php';
    include 'DBLibrary/openDB.php';

//    select specified database in config.php
    mysql_select_db($dbname);


   $queryExisting = mysql_query("select * from `rotaract`.`agenda` where place='$place'");
    $resultExisting = mysql_fetch_array($queryExisting);

    if (empty($resultExisting)) {
        $confirm = mysql_query("INSERT INTO `rotaract`.`agenda` (`date`, `place`, `desc`, `sTimeAgenda`,`eTimeAgenda`) VALUES ('$date', '$place', '$desc', '$sTimeAgenda', '$eTimeAgenda');") or die(mysql_error());
    }
include 'DBLibrary/closeDB.php';
}
?>